﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using InkFx.WinControl.Core;

namespace Temp_20190814_AForm6.Dock
{
    public class DockSplitControl2 : System.Windows.Forms.UserControl
    {
        public DockSplitControl2()
        {
            SetStyle(Win32API.ControlStylesUAORSD, true);
            base.BackColor = Color.Transparent;
            m_Panel1 = new DockSplitPanel(this);
            m_Panel2 = new DockSplitPanel(this);
        }

        protected bool m_IsSplitterFixed;
        protected DockSplitPanel m_Panel1;
        protected DockSplitPanel m_Panel2;

        /// <summary>
        /// 获取或设置一个值，用以指示拆分器是固定的还是可移动的。
        /// </summary>
        public bool IsSplitterFixed
        {
            get { return m_IsSplitterFixed; }
            set { m_IsSplitterFixed = value; }
        }

        /// <summary>
        /// Panel1 和 Panel2 之间的拆分关系
        /// </summary>
        public double SplitterDistance
        {
            get { return 0; }
        }


    }

    public class DockSplitPanel : System.Windows.Forms.Panel
    {
        public DockSplitPanel(DockSplitControl2 owner)
        {
            SetStyle(Win32API.ControlStylesUAORSD, true);
            base.BackColor = Color.Transparent;
            m_Owner = owner;
        }

        protected DockSplitControl2 m_Owner;
        public DockSplitControl2 Owner
        {
            get { return m_Owner; }
        }

        protected override void OnParentChanged(EventArgs e)
        {
            base.OnParentChanged(e);
            if (this.Parent != null && this.Parent != m_Owner)
                throw new Exception("DockSplitPanel 的 父级控件 必须和 Owner 相同");
        }


    }
}
